package com.lzy.managersystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzy.managersystem.mapper.CourseMapper;
import com.lzy.managersystem.pojo.Course;
import com.lzy.managersystem.service.CourseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author qq619
 * @description 针对表【course】的数据库操作Service实现
 * @createDate 2022-07-17 11:12:39
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course>
        implements CourseService {

    @Resource
    private CourseMapper courseMapper;

    @Override
    public List<Course> getAllUser() {
        return courseMapper.selectAll();
    }

    @Override
    public int insterUser(Course course) {
        return courseMapper.insertSelective(course);
    }

    @Override
    public int deleteUser(Integer id) {
        return courseMapper.delById(id);
    }

    @Override
    public int updateUser(Course course) {
        return courseMapper.updateSelective(course);
    }

    @Override
    public int deleteBatchUser(List<Integer> ids) {
        return courseMapper.deleteBatchIds(ids);
    }

    @Override
    public Page<Course> pageInfo(Page<Course> courseIPage, String name) {
        return courseMapper.findPage(courseIPage, name);
    }

    @Override
    public List<Course> courseByteacherId(String id) {
        return courseMapper.findCourseByid(id);
    }

    @Transactional
    @Override
    public int updateCourse(Integer courseId, Integer studentId) {
        int d = courseMapper.delCourse(courseId, studentId);
        int u = courseMapper.updateCourse(courseId, studentId);
        return d + u;
    }

    @Override
    public List<Course> stuCourse(Integer id) {
        return courseMapper.findStuCourse(id);
    }


}




